package org.springblade.modules.repair.service.impl;

import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.repair.service.PlanHistoryImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.repair.entity.MaintainCheckRecord;
import org.springblade.modules.repair.mapper.MaintainCheckRecordMapper;
import org.springblade.modules.repair.service.MaintainCheckRecordService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MaintainCheckRecordServiceImpl extends BaseServiceImpl<MaintainCheckRecordMapper, MaintainCheckRecord> implements MaintainCheckRecordService{

	@Autowired
	@Lazy
	private PlanHistoryImageService planHistoryImageService;

	@Override
	public List<MaintainCheckRecord> listByCheckHistoryIds(List<Long> checkHistoryIds) {
		return baseMapper.listByCheckHistoryIds(checkHistoryIds);
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public Boolean addCheckRecord(MaintainCheckRecord entity) {
		super.saveOrUpdate(entity);
		planHistoryImageService.removeByPlan(entity.getPlanId());
		return Boolean.TRUE;
	}
}
